#!/usr/bin/python
# -*- coding: UTF-8 -*-

from kpautos.engine.case import Case
from kptest.config.enum import DeviceType, HostType, DeviceUtility
from extension.utils import password_generator


class BMC_Redfish_03(Case):
    """
        Name:
            BMC_Redfish_03
        Label:
            查看内存信息
        PreCondition:
            1、BMC正常运行
        TestStep:
            1、发送redfish请求，查看内存信息
        ExpectedResult:
            A）Redfish可以正常显示内存信息
        Parameters:

        Remark:

    """

    # 测试执行前配置等准备操作
    def pre_test_case(self):
        self.device_dut = self.resource.get_device(device_type=DeviceType.Server, utility=DeviceUtility.DUT)
        self.os_host = self.device_dut.get_host(host_type=HostType.HostOS)
        self.redfish_api = self.device_dut.get_api(ns_name="Redfish")

        # 测试步骤
    def procedure(self):
        self.log_step(" 1、发送请求，检查内存信息")
        result = self.redfish_api.redfish_systems_query_system_id('1/Memory')
        self.logger.info(f"Redfish查询到的内存信息为：{result}")
        if result == None:
            raise Exception("Redfish检查CPU信息失败")
        self.log_step("2、查询内存详细信息")
    # 测试结束后恢复环境
    def post_test_case(self):
        pass
